function getHTTPObject() {
  var xhr = false;
  if (window.XMLHttpRequest) {
    xhr = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      try {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
      } catch(e) {
        xhr = false;
      }
    }
  }
  return xhr;
}
function sendData(data, target, callback) {
  request = getHTTPObject();
  if (request) {
    request.onreadystatechange = function(){
        callback(request);
    }
    request.open( "POST", target, true );
    request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    request.send(data);
    return true;
  } else {
    return false;
  }
}
function load(){
    sendData("", "http://localhost/wekaws/list_model_service.php", function(){
        if (request.readyState == 4){
            if (request.status == 200 || request.status == 304) {
                var JSONtext = request.responseText;
                models = JSON.parse(JSONtext);
                var model_view = document.getElementById("model_view");
                model_view.value = "-";
                for (var i=0; i<models.length; i++){
                    var opsi = document.createElement("option");
                    opsi.value = i;
                    opsi.innerHTML = models[i].model_name;
                    model_view.appendChild(opsi);
                }
            }
        } 
    });
}
function change(){
    var model_view = document.getElementById("model_view");
    var model_name = document.getElementById("model_name");
    var n = model_view.value;
    var model = models[n];
    model_name.value = model.model_name;
    
    for(var i=0; i< model.attribute.length; i++){
        if (model.attribute[i] == '0') {
            var d = document.getElementById("attr"+i);
            d.disabled = true;
            d.value = "?";
        }
        
    }
}